package letsjava.rmi;

import java.rmi.*;
import java.util.*;


import javax.naming.*;

public class WarehouseClient {
	public static void main(String[] args) throws NamingException, RemoteException{
		Context context = new InitialContext();
		Enumeration<NameClassPair> name = context.list("rmi://127.0.0.1/");
		while(name.hasMoreElements()){
			System.out.println(name.nextElement().getName());
		}
		
		String url = "rmi://127.0.0.1/warehouse";
		Warehouse warehouse = (Warehouse) context.lookup(url);
		List<String> keywords = new ArrayList<String>();
		keywords.add("apple");
		keywords.add("pear");
		System.out.println(warehouse.getProduct(keywords));
		
	}
}
